<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/index3.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery-3.2.1.js"></script>
    <script src="${pageContext.request.contextPath}/static/My97DatePicker/WdatePicker.js"></script>
</head>

<body>
<form action="./add" method="post">
    订单编号:<input type="text" name="orderNum" value="${l}">
    订单日期:<input type="text" name="orderTime">
    制单人工号:<input type="text" name="users.userNumber" value="${LOGIN_USER.userNumber}">
    相关需求:<input type="text" name="orderNeed">
    制单人:<input type="text" name="users.userName" value="${LOGIN_USER.userName}">
    制单时间:<input type="text" name="tauchingTime">
    相关资料:<input type="text" name="img">
    <div id="phonto"></div>
    总薪酬:<input type="text" name="salary" readonly>
    备注:<input type="text" name="remark">
    <input type="button" value="增加" onclick="zj()">
    <h1>专家明细</h1>
    <table id="tb">
        <tr>
            <td>专家编号</td>
            <td>专家姓名</td>
            <td>专业方向</td>
            <td>电话1</td>
            <td>电话2</td>
            <td>薪酬</td>
            <td>合作时长</td>
            <td>开始时间</td>
            <td>结束时间</td>
            <td>操作状态</td>
            <td>审批状态</td>
            <td>操作</td>
        </tr>
        <tr>
            <td><input type="text" name="details[0].detailNum" onblur="cz(0)"></td>
            <td><input type="text" name="details[0].detailName"></td>
            <td><input type="text" name="details[0].detailDirection"></td>
            <td><input type="text" name="details[0].phone1"></td>
            <td><input type="text" name="details[0].phone2"></td>
            <td><input type="text" name="details[0].money" class="m" onchange="gb()"></td>
            <td><input type="text" name="details[0].cooperation"></td>
            <td><input type="text" name="details[0].starttime"></td>
            <td><input type="text" name="details[0].endtime"></td>
            <td><input type="text" name="details[0].caoStatus" onchange="shen(0)"></td>
            <td><input type="text" name="details[0].shenStatus"></td>
            <td><input type="button" name="details[0].status" onclick="sh(0)"></td>

        </tr>
    </table>
    <input type="button" value="保存" onclick="bc()">
</form>
<script>
$(function () {
  $("#phonto").load("mmcrofile/toup2");

})
  function uploadOk(fileName) {
   $('[name="img"]').val(fileName);
  }
    var i=1;
    function zj() {
      $("#tb").append(' <tr>\n' +
          '            <td><input type="text" name="details['+i+'].detailNum" onblur="cz('+i+')"></td>\n' +
          '            <td><input type="text" name="details['+i+'].detailName"></td>\n' +
          '            <td><input type="text" name="details['+i+'].detailDirection"></td>\n' +
          '            <td><input type="text" name="details['+i+'].phone1"></td>\n' +
          '            <td><input type="text" name="details['+i+'].phone2"></td>\n' +
          '            <td><input type="text" name="details['+i+'].money" class="m" onchange="gb()"></td>\n' +
          '            <td><input type="text" name="details['+i+'].cooperation"></td>\n' +
          '            <td><input type="text" name="details['+i+'].starttime"></td>\n' +
          '            <td><input type="text" name="details['+i+'].endtime"></td>\n' +
          '            <td><input type="text" name="details['+i+'].caoStatus" ></td>\n' +
          '            <td><input type="text" name="details['+i+'].shenStatus"></td>\n' +
          ' <td><input type="button" name="details[0].status" onclick="sh('+i+')"></td>\n'+
          '        </tr>')
        i++;
    }
function cz(obj) {

 var num= $('[name="details['+obj+'].detailNum"]').val();
 $.post("bynum",{num:num},function (thiz) {
    if(thiz==1){
      alert("用户已存在")
    }else{
        alert("444")
    }
 })
}
    function sh(obj) {
        var name=$('[name="details['+obj+'].detailNum"]').val();
        var time=$('[name="details['+obj+'].cooperation"]').val();
        var salay=$('[name="details['+obj+'].money"]').val();
        alert(salay);
        alert(time)
       $.post("./shehe",{name:name,time:time,salay:salay},function (thiz) {
           alert(thiz)
           $('[name="details['+obj+'].caoStatus"]').val("已审核");
           $('[name="details['+obj+'].shenStatus"]').val(thiz);
       })
    }

    function shen(obj) {
    var zhi=$('[name="details['+obj+'].caoStatus"]').val();
    alert(zhi)
    if(zhi=='未审核'){
        $('[name="details['+obj+'].status"]').prop("disabled",false)
       var hh=$('[name="details['+obj+'].status"]').val("去审核");
       alert(hh)
    }else{
        var hh=$('[name="details['+obj+'].status"]').val('');
        $('[name="details['+obj+'].status"]').prop("disabled",true)
        // alert("00000")
        // $('[name="details['+obj+'].caoStatus"]').parent().parent().append('<td><a src=""></a></td>')
    }
}
    function gb(){
        var summonry=0;
        $(".m").each(function () {
            var money=$(this).val();
            summonry+=Number(money)
        })
        $('[name="salary"]').val(summonry);
    }
function bc() {
    $("#nr").load("./add?"+$('form').serialize());
}
</script>
</body>
</html>
